M84 Z

M291 R"True Bed Leveling Test" P"Tilt the bed manually to test the True Bed Leveling." S4 K{"Test","Skip","Cancel"}
if input == 1
    M99
elif input == 2
    abort "Test cancelled by user"

M291 R"True Bed Leveling Test" P"Please adjust the bed position manually. After pressing “OK,” homing Z will start." S2
G28

M291 R"Z - Axis Lubracation" P"Do you want to lubricate the Z-Axis?<br>Press and hold X or U endtop to stop" S4 K{"Start","Skip","Cancel"}
if input == 1
    M99
elif input == 2
    abort "Test cancelled by user"

; Ensure XYU axes are homed
if !move.axes[0].homed || !move.axes[1].homed || !move.axes[3].homed
    G28 Y
    G28 X
    G28 U

G90
G1 X-999 U999 Y0 F18000

G1 Z450 F18000
M291 R"Z - Axis Lubrication" P"Apply lubricant to the lead screw now.<br><br><b>To stop oscillation:</b> Press and hold X or U endstop" S4 K{"Start Z Lubrication","Cancel"}
if input == 1
    abort "Test cancelled by user"
M400

var coef = 1

while true
    if move.axes[2].machinePosition >= 435
        set var.coef = 1
    if move.axes[2].machinePosition <= 15
        set var.coef = -1


    if sensors.endstops[0].triggered || sensors.endstops[3].triggered
        break
    G1 Z{move.axes[2].machinePosition - (var.coef*30)} F18000
    M400
    if sensors.endstops[0].triggered || sensors.endstops[3].triggered
        break
    G1 Z{move.axes[2].machinePosition + (var.coef*15)} F18000
    M400

G1 Z300 F18000